package com.example.d10_homework.homework04;


/**
 * 线程任务类
 */
public class EntranceTask implements Runnable {
    private int num;

    public EntranceTask(int num) {
        this.num = num;
    }

    @Override
    public void run() {
        // 统计每个路口的数量
        int count = 0;
        String name = Thread.currentThread().getName();
        while (true) {
            synchronized (this) {
                if (num <= 0) {
                    break;
                }
                System.out.println("编号为" + num + "的员工从" + name + "入口拿到的号码是" + DoubleColorBallUtils.createDoubleColorBall());
                num--;
                count++;
            }
        }
        System.out.println("从" + name + "入场的员工人数为" + count);
    }
}
